package com.sline.Enum;

public class Demo1_Enum {
    public static void main(String[] args) {
        // demo1();

        // demo2();

        Month1 jan = Month1.JAN;
        Month1 feb = Month1.FEB;
        Month1 mar = Month1.MAR;
        Month1 mar1 = Month1.MAR;

        System.out.println(jan.ordinal());
        System.out.println(feb.ordinal());
        System.out.println(mar.ordinal());

        // 比较的是编号
        System.out.println(jan.compareTo(feb));
        System.out.println(mar.compareTo(mar1));

        // 获取实例名称
        System.out.println(jan.name());

        System.out.println(jan.toString());

        Month jan1 = Month.valueOf(Month.class, "JAN");
        System.out.println(jan1);

        Month2[] arr = Month2.values();
        for (Month2 mon: arr) {
            System.out.println(mon);
        }
    }

    private static void demo2() {
        Month2 jan = Month2.JAN;
        switch (jan) {
            case JAN:
                System.out.println("一月");
                break;
            case FEB:
                System.out.println("二月");
                break;
            case MAR:
                System.out.println("三月");
                break;
            default:
                System.out.println("其他月份");
                break;

        }
    }

    private static void demo1() {
        Week2 MON = Week2.MON;
        System.out.println(MON.getName());

        Week3 TUE = Week3.TUE;
        TUE.show();

        Month JAN = Month.JAN;
        System.out.println(JAN);

        Month1 FEB = Month1.FEB;
        System.out.println(FEB);

        Month2 MAR = Month2.MAR;
        MAR.show();
        System.out.println(MAR);
    }
}
